<script setup lang="ts">
import { propTypes } from '@jctech/utils/propTypes';
import { isNullOrWhiteSpece } from '@jctech/utils/is';
import { nl2br, space2Html } from '@jctech/utils/domUtils';
import { xssHtmlFilter } from '@jctech/utils/xssfilter';
import { computed } from 'vue';

const props = defineProps({
  content: propTypes.string.def(''),
  defaultContent: propTypes.string.def(''),
  format: propTypes.bool.def(true)
});

defineOptions({
  name: 'CTextareaShow'
});

const Vcontent = computed(() => {
  if (isNullOrWhiteSpece(props.content)) {
    return props.defaultContent;
  }
  if (props.format) {
    return space2Html(nl2br(xssHtmlFilter(props.content)));
  }
  return props.content;
});
</script>

<template>
  <div v-html="Vcontent"></div>
</template>

<style lang="less"></style>
